home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / XAMPP 1.4.14 / xampp-win32-1.4.14-installer.exe / xampp / php / pear / data / Mail_Mime / xmail.xsl < prev   
Extensible Markup Language  |  2004-03-24  |  2KB  |  70 lines

  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
  3. <xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
  4. <xsl:preserve-space elements="headervalue paramvalue body"/>
  5.  
  6.     <xsl:template name="mimepart">
  7.  
  8.         <xsl:variable name="boundary">
  9.                 <xsl:for-each select="./header">
  10.                     <xsl:if test="string(./headername) = 'Content-Type'">
  11.                         <xsl:for-each select="./parameter">
  12.                             <xsl:if test="string(./paramname) = 'boundary'">
  13.                                 <xsl:value-of select="paramvalue"/>
  14.                             </xsl:if>
  15.                         </xsl:for-each>
  16.                     </xsl:if>
  17.                 </xsl:for-each>
  18.         </xsl:variable>
  19.  
  20.         <xsl:for-each select="header">
  21.  
  22.             <xsl:value-of select="headername"/>
  23.             <xsl:text>: </xsl:text>
  24.             <xsl:value-of select="headervalue"/>
  25.  
  26.             <xsl:if test="count(./parameter) = 0">
  27.                 <xsl:text> </xsl:text>
  28.             </xsl:if>
  29.  
  30.             <xsl:for-each select="parameter">
  31.                 <xsl:text>; </xsl:text>
  32.                 <xsl:value-of select="paramname"/>
  33.                 <xsl:text>="</xsl:text>
  34.                 <xsl:value-of select="paramvalue"/>
  35.                 <xsl:text>"</xsl:text>
  36.             </xsl:for-each>
  37.  
  38.             <xsl:if test="count(./parameter) > 0">
  39.                 <xsl:text> </xsl:text>
  40.             </xsl:if>
  41.  
  42.         </xsl:for-each>
  43.  
  44.         <xsl:text> </xsl:text>
  45.  
  46.         <!-- Which to do, print a body or process subparts? -->
  47.         <xsl:choose>
  48.             <xsl:when test="count(./mimepart) = 0">
  49.                 <xsl:value-of select="body"/>
  50.                 <xsl:text> </xsl:text>
  51.             </xsl:when>
  52.  
  53.             <xsl:otherwise>
  54.                 <xsl:for-each select="mimepart">
  55.                     <xsl:text>--</xsl:text><xsl:value-of select="$boundary"/><xsl:text> </xsl:text>
  56.                     <xsl:call-template name="mimepart"/>
  57.                 </xsl:for-each>
  58.  
  59.                 <xsl:text>--</xsl:text><xsl:value-of select="$boundary"/><xsl:text>-- </xsl:text>
  60.  
  61.             </xsl:otherwise>
  62.         </xsl:choose>
  63.     </xsl:template>
  64.  
  65. <!-- This is where the stylesheet really starts, matching the top level email element -->
  66.     <xsl:template match="email">
  67.         <xsl:call-template name="mimepart"/>
  68.     </xsl:template>
  69.  
  70. </xsl:stylesheet>